#!/usr/bin/env python
#coding=utf-8
from datetime import timedelta
from models.base import db
from common.utils import html2textile
from pitaya.v1.article.view import web_article
from pitaya.v1.user.view import user
from pitaya.v1.tag.view import tags

from flask import Flask, current_app
app = Flask(__name__)
app.config.from_object('config')


def create_app():
    if not current_app:
        app = Flask(__name__)
    else:
        app = current_app
    return app


app = create_app()
app.config.from_object('config')
app.config.from_object(__name__)
app.config['SECRET_KEY'] = '123456'
db.init_app(app)
app.debug = True
# app.secret_key = MyConfObj.SECRET_KEY
# app.session_cookie_name = MyConfObj.COOKIE_DOMAIN
app.permanent_session_lifetime = timedelta(seconds=60 * 60 * 24)
app.add_template_filter(html2textile, "html2textile")

app.register_blueprint(web_article)
app.register_blueprint(user)
app.register_blueprint(tags)

#
# if __name__ == '__main__':
#     app.run(host='0.0.0.0', debug=True)